package com.banciyuan.bcywebview.utils.intent;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.banciyuan.bcywebview.biz.login.LoginActivity;
import com.banciyuan.bcywebview.biz.main.MainActivity;

import java.io.Serializable;

/**
 * activity 跳转函数
 * 封装了跳转，所有的参数名字都规定好了
 *
 * @author hfxt2008
 */
public class gotoUtil {

    public final static String INTENT_VALUE_ONE = "valueone";
    public final static String INTENT_VALUE_TWO = "valuetwo";
    public final static String INTENT_VALUE_THREE = "valuethree";
    public final static String INTENT_VALUE_FOUR = "valuefour";
    public final static String INTENT_VALUE_FIVE = "valuefive";
    public final static String INTENT_VALUE_SIX = "valuesix";
    public final static String NEEDLOGOUT = "needlogout";
    public final static String FORMPUSH = "formpush";
    public final static String SELECTEDITEM = "selecteditem";

    public final static String INTENT_OTYPE_DATA = "";

    public static void gotoAct(Context ctx, Class<?> cls) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, int valueone) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, String valueone) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, Serializable valueone) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, Serializable valueone, String valuetwo) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, int valueone, Serializable valuetwo) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, int valueone, String valuetwo) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, String valueone, String valuetwo) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, String valueone, String valuetwo, String valuethree, String valuefour, String valueFive) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra(INTENT_VALUE_THREE, valuethree);
        intent.putExtra(INTENT_VALUE_FOUR, valuefour);
        intent.putExtra(INTENT_VALUE_FIVE, valueFive);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, String valueone, String valuetwo, String valuethree, String valuefour) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra(INTENT_VALUE_THREE, valuethree);
        intent.putExtra(INTENT_VALUE_FOUR, valuefour);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, int valueone, String valuetwo, String valuethree) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra(INTENT_VALUE_THREE, valuethree);
        ctx.startActivity(intent);
    }

    public static void gotoActAmin(Context ctx, Class<?> cls, int rIdIn, int rIdOut) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        ctx.startActivity(intent);
        ((Activity) ctx).overridePendingTransition(rIdIn, rIdOut);
    }

    public static void replaceAct(Context ctx, Class<?> cls) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceLogin(Context ctx) {
        try {
            if (ctx == null) return;
            Intent intent1 = new Intent(ctx, MainActivity.class);
            intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            Intent intent2 = new Intent(ctx, LoginActivity.class);
            ctx.startActivities(new Intent[]{intent1, intent2});
            ((Activity) ctx).finish();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void replaceMainClearTop(Context ctx) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, MainActivity.class);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceAct(Context ctx, Class<?> cls, String valueone) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceAct(Context ctx, Class<?> cls, Boolean valueone) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceAct(Context ctx, Class<?> cls, Boolean valueone, String valuetwo) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceAct(Context ctx, Class<?> cls, String valueone, String valuetwo) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceAct(Context ctx, Class<?> cls, String valueone, String valuetwo, String valuethree) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra(INTENT_VALUE_THREE, valuethree);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceAct(Context ctx, Class<?> cls, Boolean valueone, String valuetwo, Boolean valuethree) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra(INTENT_VALUE_THREE, valuethree);
        ctx.startActivity(intent);
        ((Activity) ctx).finish();
    }

    public static void replaceActAmin(Context ctx, Class<?> cls, int rIdIn, int rIdOut) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        ctx.startActivity(intent);
        ((Activity) ctx).overridePendingTransition(rIdIn, rIdOut);
        ((Activity) ctx).finish();
    }

    //以下方法 仅在discoverFragment中跳转热门acitivity中使用
    public static void gotoAct(Context ctx, Class<?> cls, String valueone, String valuetwo, int from) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra("from", from);
        ctx.startActivity(intent);
    }

    //以下方法 仅在discoverFragment中跳转热门acitivity中使用
    public static void gotoAct(Context ctx, Class<?> cls, String valueone, int from) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra("from", from);
        ctx.startActivity(intent);
    }

    public static void gotoAct(Context ctx, Class<?> cls, String valueone, String valuetwo, String valueThree) {
        if (ctx == null) return;
        Intent intent = new Intent(ctx, cls);
        intent.putExtra(INTENT_VALUE_ONE, valueone);
        intent.putExtra(INTENT_VALUE_TWO, valuetwo);
        intent.putExtra(INTENT_VALUE_THREE, valueThree);
        ctx.startActivity(intent);
    }
}